//
//  DotView.m
//  HiveApp
//
//  Created by Zhu Xiangjun on 9/27/12.
//  Copyright (c) 2012 HiveView. All rights reserved.
//

#import "DotView.h"
#define TAG_CONSTANT 10
@implementation DotView

- (void)makeDots:(NSArray*) focusArray{
        
        int count = [focusArray count];
        self.frame = CGRectMake(self.frame.size.width/2-15*count/2, self.frame.origin.y, 15*count, 10 ) ;
            
        for( int i = 0 ; i < count ; i++){
            
            UIImageView *dotImageView  = [[UIImageView alloc] initWithFrame:CGRectMake(15*i, 0, 5, 5)];
            [dotImageView setImage:[UIImage imageNamed:@"DotGray.png"]];
            [self addSubview:dotImageView];
            [dotImageView release];
        }
    
    [self dotFocused:0];
        
}

-(void)dotFocused:(int)page{
    

    NSArray *subViews = [self subviews];
    int count = [subViews count];
    
    for( int i = 0 ; i < count ; i++){
        
        UIImageView *dotImageView = [subViews objectAtIndex:i];
        
        if(i == page){
            
            [dotImageView setImage:[UIImage imageNamed:@"DotRed.png"]];
            
        }else{
            
            [dotImageView setImage:[UIImage imageNamed:@"DotGray.png"]];
            
        }
        
    }
        
}


@end
